﻿using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

public partial struct EnemyMoveSystem : ISystem
{


    [BurstCompile]
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<BattleSceneTag>();
    }

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        var deltaTime = SystemAPI.Time.DeltaTime;

        //往前走 获得所有敌人
        foreach (var (enemyData, transform) in SystemAPI.Query<EnemyData, RefRW<LocalTransform>>())
        {
            var dir = -1;
            var moveSpeed = enemyData.MoveSpeed;
            var moveDeltaZ = dir * moveSpeed * deltaTime;
            transform.ValueRW.Position += new float3(0, 0, moveDeltaZ);
        }
    }

}